<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>M2M MCP SSH Key Server</title>
        <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 1000px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f9fafb;
        }
        header {
            background-color: #2c3e50;
            color: white;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 30px;
        }
        h1 {
            margin: 0;
        }
        .subtitle {
            color: #ddd;
            font-weight: 300;
        }
        h2 {
            border-bottom: 2px solid #eaecef;
            padding-bottom: 10px;
            margin-top: 40px;
            color: #2c3e50;
        }
        .endpoint {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
            padding: 20px;
            margin-bottom: 20px;
        }
        .endpoint h3 {
            margin-top: 0;
        }
        .method {
            display: inline-block;
            padding: 5px 10px;
            border-radius: 4px;
            font-weight: bold;
            color: white;
            margin-right: 10px;
        }
        .get {
            background-color: #61affe;
        }
        .post {
            background-color: #49cc90;
        }
        code {
            background-color: #f1f1f1;
            padding: 2px 5px;
            border-radius: 3px;
            font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
        }
        pre {
            background-color: #f6f8fa;
            padding: 16px;
            border-radius: 5px;
            overflow-x: auto;
            border: 1px solid #ddd;
        }
        .status {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 3px;
            font-size: 14px;
            margin-right: 5px;
            color: white;
        }
        .status-200 {
            background-color: #49cc90;
        }
        .status-400 {
            background-color: #f93e3e;
        }
        .status-415 {
            background-color: #f93e3e;
        }
        .status-429 {
            background-color: #f93e3e;
        }
        .status-500 {
            background-color: #f93e3e;
        }
        .endpoint-link {
            color: #0366d6;
            text-decoration: none;
            font-weight: 500;
        }
        .endpoint-link:hover {
            text-decoration: underline;
        }
        footer {
            margin-top: 50px;
            padding-top: 20px;
            border-top: 1px solid #eaecef;
            color: #6c757d;
            font-size: 0.9em;
            text-align: center;
        }
        </style>
    </head>
    <body>
        <header>
            <h1>M2M MCP SSH Key Server</h1>
            <p class="subtitle">Key Management API</p>
        </header>
        <div>
            <p>
                This service provides an API for SSH key registration and management between M2M MCP clients and servers. Use these endpoints to register client keys and retrieve the server's public key.
            </p>
            <h2>API Endpoints</h2>
            <div class="endpoint">
                <h3>
                    <span class="method post">POST</span> /register
                </h3>
                <p>Register a client public SSH key with the server to allow future SSH connections.</p>
                <h4>Request</h4>
                <p>
                    Content-Type: <code>application/json</code>
                </p>
                <pre>{
    "client_pub_key": "ssh-rsa AAAAB3NzaC1yc2E... client-name"
}</pre>
                <h4>Response</h4>
                <p>Success:</p>
                <pre>{
    "status": "success"
}</pre>
                <p>Error:</p>
                <pre>{
    "error": "Failed to register key"
}</pre>
                <h4>Status Codes</h4>
                <p>
                    <span class="status status-200">200</span> Success
                    <br>
                    <span class="status status-400">400</span> Bad Request - Invalid key format or missing field
                    <br>
                    <span class="status status-415">415</span> Unsupported Media Type - Content-Type must be application/json
                    <br>
                    <span class="status status-429">429</span> Too Many Requests - Rate limit exceeded
                    <br>
                    <span class="status status-500">500</span> Internal Server Error
                </p>
            </div>
            <div class="endpoint">
                <h3>
                    <span class="method get">GET</span> <a href="/server_pub_key" class="endpoint-link">/server_pub_key</a>
                </h3>
                <p>Retrieve the server's public SSH key to set up trusted connections.</p>
                <h4>Response</h4>
                <pre>{
    "server_pub_key": "ssh-rsa AAAAB3NzaC1yc2E... server@hostname"
}</pre>
                <h4>Status Codes</h4>
                <p>
                    <span class="status status-200">200</span> Success
                    <br>
                    <span class="status status-429">429</span> Too Many Requests - Rate limit exceeded
                </p>
            </div>
            <div class="endpoint">
                <h3>
                    <span class="method get">GET</span> <a href="/health" class="endpoint-link">/health</a>
                </h3>
                <p>Check the health status of the API server.</p>
                <h4>Response</h4>
                <pre>{
    "status": "healthy"
}</pre>
                <h4>Status Codes</h4>
                <p>
                    <span class="status status-200">200</span> Success
                    <br>
                    <span class="status status-429">429</span> Too Many Requests - Rate limit exceeded
                </p>
            </div>
        </div>
        <footer>
            <p>Machine To Machine &copy; 2025</p>
        </footer>
    </body>
</html>
